home *** CD-ROM | disk | FTP | other *** search
- Path: news.iadfw.net!usenet
- From: jveigel@airmail.net (Jens Veigel)
- Newsgroups: comp.lang.c++
- Subject: Is there an easier way to do this in C ?
- Date: Mon, 08 Apr 1996 04:35:27 GMT
- Organization: Guest user
- Message-ID: <4kcpio$a0o@airnews.iadfw.net>
- NNTP-Posting-Host: dal36-27.ppp.iadfw.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- I'm porting an ASPECT (Procomm f win) script to C in Windows and I'm
- at the portion where I need to build several list.txt files for my
- comboboxes to display filenames longer than 8 characters. The way I do
- it in my script is to "cruise" the directories stuff them into an
- array and then build the files. My question is:
-
- Is there an easier way to do this than the script below ?
- If not I will have to port it to C and add the missing features like
- stringinsert and stringextract myself and do it the way I'm doing it
- now. I'm just wondering if I could somehow use some sort of lookup
- table where I would store my created dir structure each time a sub dir
- is created or deleted, instead of having to run this everytime a new
- subdir under the "\top & \bot" has been created, so I'm current as
- far as my file combobox text files are concerned. I reverse the
- process when a filename of lets say 69557904031 has been picked from
- the combobox, I then insert slashes and build a path like so
- d:\mpm\line1\top\695\57904031\*.* from which I transmit files.
- Not only takes an array this size a lot of memory but also some time
- to "cruise through the dirs to which I add daily 4 or five.
- BTW: what's the equivalent to $nullstr in C ?
-
- Any suggestions would be greatly appreciated.
-
- here is how I do it today, again this is not C but aspect but looks
- almost like C, except strings are diff in C and of course the array
- would be differently acessed ....
-
- string FabArray[10][200][20]
- string linedef, Linedef1t , Linedef1b, Linedef2t, Linedef2b,
- Linedef3t, Linedef3b
-
- string Filelist
- string Listfile
-
-
- proc MAIN
-
- Linedef="d:\mpm"
- Linedef1t="d:\mpm\line1\top"
- Linedef1b="d:\mpm\line1\bot"
- Linedef2t="d:\mpm\line2\top"
- Linedef2b="d:\mpm\line2\bot"
- Linedef3t="d:\mpm\line3\top"
- Linedef3b="d:\mpm\line3\bot"
-
-
-
- Listfile="Line.txt"
- strcpy Linedef Linedef1t ;line1\top
- filelist=Linedef
- GetList(Linedef)
-
- pause 2
- strcpy Linedef Linedef2t ;line2\top
- filelist=Linedef
- GetList(Linedef)
-
- pause 2
- strcpy Linedef Linedef3t ;line3\top
- filelist=Linedef
- GetList(Linedef)
-
-
-
- pause 2
- strcpy Linedef Linedef1b ;line1\bottom
- filelist=Linedef
- GetList(Linedef)
-
-
- pause 2
- strcpy Linedef Linedef2b ;line2\bottom
- filelist=Linedef
- GetList(Linedef)
-
-
-
- pause 2
- strcpy Linedef LineDef3b ;line3\bottom
- filelist=Linedef
- GetList(Linedef)
-
- endproc
-
-
- proc Getlist
- param string Leader
- integer one, two, three
- string line, strvar1, strvar2, strvar3, Level1, Level2, Level3
-
- ;clear any old array contents
- for one=0 upto 9
- for two=0 upto 199
- for three=0 upto 19
- FabArray[one][two][three]=$nullstr
- endfor
- endfor
- endfor
-
- ; get subdirectories in the first level
- one=0
- strvar1=Leader
- addfilename strvar1 "*.*"
- if findfirst strvar1 "D" ; findfirst Level1
- Level1=$filename
- strfind Level1 "."
- if failure
- FabArray[one][0][0]=Level1
- strcat Level1 " "
- strupr level1
- usermsg level1
- one++
- endif
- while findnext ; findnext Level1
- Level1=$filename
- if strfind Level1 "."
- loopwhile
- else
- FabArray[one][0][0]=Level1
- one++
- endif
- endwhile
- endif
- ; get subdirectories in the second level
- for one=0 upto 29
- two=1
- strvar2=FabArray[one][0][0]
- if strcmp strvar2 $nullstr
- exitfor
- else
- strinsert strvar2 "\" 0
- strinsert strvar2 Leader 0
- addfilename strvar2 "*.*"
- endif
- if findfirst strvar2 "D" ; findfirst
- Level2
- Level2=$filename
- strfind Level2 "."
- if failure
- strcmp Level2 $nullstr
- if failure
- FabArray[one][two][0]=Level2
- two++
- endif
- endif
- while findnext ; findnext
- Level2
- Level2=$filename
- if strfind Level2 "."
- loopwhile
- else
- strcmp Level2 $nullstr
- if failure
- FabArray[one][two][0]=Level2
- two++
- else
- exitwhile
- endif
- endif
- endwhile
- endif
- endfor
- ; get subdirectories in the third level
- for one=0 upto 9
- for two=1 upto 199
- three=1
- Level1=FabArray[one][0][0]
- Level2=FabArray[one][two][0]
- strvar3=Level2
- if strcmp strvar3 $nullstr
- exitfor
- else
- strinsert strvar3 "\" 0
- strinsert strvar3 Level1 0
- strinsert strvar3 "\" 0
- strinsert strvar3 Leader 0
- addfilename strvar3 "*.*"
- endif
- if findfirst strvar3 "D" ; findfirst
- Level3
- Level3=$filename
- strfind Level3 "."
- if failure
- strcmp Level3 $nullstr
- if failure
- FabArray[one][two][three]=Level3
- three++
- endif
- endif
- while findnext ; findnext
- Level3
- Level3=$filename
- if strfind Level3 "."
- loopwhile
- else
- strcmp Level3 $nullstr
- if failure
- FabArray[one][two][three]=Level3
- three++
- else
- exitwhile
- endif
- endif
- endwhile
- endif
- endfor
- endfor
- ; generate file for use in fcombobox
- ;fetch aspect path FileList
-
- addfilename FileList listfile
-
- fopen 0 FileList create text
-
- for one=0 upto 9
- Level1=FabArray[one][0][0]
- if strcmp Level1 $nullstr
- exitfor
- endif
- for two=1 upto 199
- Level2=FabArray[one][two][0]
- if strcmp Level2 $nullstr
- if two==1
- fputs 0 Level1
- endif
- exitfor
- else
- for three=1 upto 19
- Level3=FabArray[one][two][three]
- if strcmp Level3 $nullstr
- if three==1
- line=Level1
- strcat line Level2
- fputs 0 line
- endif
- exitfor
- endif
- line=Level1
- strcat line Level2
- strcat line Level3
- fputs 0 line
- endfor
- endif
- endfor
- endfor
- fclose 0
- endproc ;GetList
-
-
-
-